package org.tigris.atlas.quizme.client.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.tigris.atlas.quizme.client.form.RegistrationForm;
import org.tigris.atlas.quizme.client.utils.Constants;
import org.tigris.atlas.quizme.transfer.UserProfile;

/**
 * Sets up the profile page using the currently logged in user
 * 
 * @author Robert Simmering
 */
public class InitializeProfileAction  extends Action {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
		      HttpServletRequest request, HttpServletResponse response) {	
		
		UserProfile userProfile = (UserProfile)request.getSession().getAttribute(Constants.USER_KEY);
		RegistrationForm regForm = new RegistrationForm();
		regForm.copyFrom(userProfile);
		
		request.setAttribute("RegistrationForm", regForm);
		return mapping.findForward("success");
	}
}
